/**
 *
 * @Author: Marek Zakowicz <mazak (at) debian (dot) linux.org.pl>
 *
 * Copyright (c) 2005, 2006, 2007 Marek Zakowicz. All rights reserved.
 *
 * Licence: This code may be used, (re)distribute and/or modify under the terms one of the following two kinds of licence:
 *          1) as free software under GPL 3 (General Public Licence ver. 3 as published by the Free Software Foundation)
 *          2) as software under the terms individual licence from Marek Zakowicz
 *
 *          This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *          without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

package jsp2php;

class StaticBoolTranslator extends PrimitiveBaseTranslator implements ITranslator {
   public String name() {
      return "boolean";
   }

   public String php_name() {
      return "bool";
   }

}

/**
 * @composed 1 - 1 BoolValueTranslator
 */
class BoolTranslator extends StaticBoolTranslator implements ITypeTranslator {
   private static BoolValueTranslator value_translator = new BoolValueTranslator();

   static {
      JavaType.add_type_translator( new BoolTranslator() );
   }

   private BoolTranslator() {}

   public IValueTranslator value_translator() {
      return value_translator;
   }
}

class BoolValueTranslator extends StaticBoolTranslator implements IValueTranslator {
   static Translation literal(boolean value) {
      return new Translation(""+value, JavaType.bool(), true, true);
   }

   public Translation literal(String value) throws TranslatorException {
      return literal(Boolean.parseBoolean(value));
   }

}
